<template>
  <div class="el-flex el-box-column">
    <el-form :inline="true" class="demo-form-inline" style="float: left;height:43px" @submit.native.prevent>
      <el-form-item>
        <el-input clearable placeholder="请输入姓名" v-model="textSearch" @keyup.enter.native="searchTabel" @clear="searchClear"
          style="width:240px;">
          <el-button slot="append" icon="el-icon-search" @click="searchTabel"></el-button>
        </el-input>
        <el-button type="primary" style="margin-left: 10px;" @click="seniorSearchDialog">
          高级查询
          <i class="el-icon-magic-stick"></i>
        </el-button>
      </el-form-item>
      <el-form-item style="float:right">
        <el-button type="primary" @click='handleTaskAdd' plain>
          新增
          <i class="el-icon-plus"></i>
        </el-button>
        <el-popover placement="bottom" width="200" trigger="hover">
          <ul class='ul-text'>
            <li>
              <el-link :underline="false" class='li-text' @click='allAdd'>批量导入新增</el-link>
            </li>
            <li>
              <el-link :underline="false" class='li-text' @click='allEdit'>批量导入更新</el-link>
            </li>
            <!-- <li>
              <el-link :underline="false" class='li-text'>批量删除</el-link>
            </li> -->
          </ul>
          <el-button type="primary" slot="reference" plain>
            批量操作
            <i class="el-icon-upload"></i>
          </el-button>
        </el-popover>
      </el-form-item>
    </el-form>
    <!-- 表格 -->
    <div class="el-flex el-box-column">
      <el-table border class='el-flex' height="100%" width="100%" :data="tableData" stripe ref="tableData">
        <el-table-column type="index" min-width="50px" label="序号" align="center" sortable show-overflow-tooltip></el-table-column>
        <el-table-column prop="humanArchCode" min-width="110px" label="档案编码" align="center" sortable
          show-overflow-tooltip></el-table-column>
        <el-table-column prop="humanArchName" min-width="70px" label="姓名" align="center" sortable show-overflow-tooltip></el-table-column>
        <el-table-column prop="cardType" min-width="110px" label="证件类型" align="center" sortable show-overflow-tooltip>
          <template slot-scope="scope">
            <span v-for="(item,index) in cardTypeDatas" :key='index'>{{scope.row.cardType==item.id?item.name:''}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="cardNo" min-width="85px" label="证件号" align="center" sortable show-overflow-tooltip></el-table-column>
        <el-table-column prop="certificateType" min-width="145px" label="证件/证书类型" align="center" sortable
          show-overflow-tooltip></el-table-column>
        <el-table-column prop="certificateName" min-width="100px" label="证书名称" align="center" sortable
          show-overflow-tooltip></el-table-column>
        <el-table-column prop="certificateLevel" min-width="70px" label="级别" align="center" sortable
          show-overflow-tooltip></el-table-column>
        <el-table-column prop="speciality" min-width="70px" label="专业" align="center" sortable show-overflow-tooltip></el-table-column>
        <el-table-column prop="certifyOrg" min-width="100px" label="发证机构" align="center" sortable show-overflow-tooltip></el-table-column>
        <el-table-column prop="certifyDate" min-width="100px" label="发证日期" align="center" sortable
          show-overflow-tooltip></el-table-column>
        <el-table-column prop="validStartDate" min-width="130px" label="有效起始日期" align="center" sortable
          show-overflow-tooltip></el-table-column>
        <el-table-column prop="validEndDate" min-width="130px" label="有效到期日期" align="center" sortable
          show-overflow-tooltip></el-table-column>
        <el-table-column prop="verifyExpireDate" min-width="100px" label="复审日期" align="center" sortable
          show-overflow-tooltip></el-table-column>
        <el-table-column prop="certificateCode" min-width="100px" label="证书编码" align="center" sortable
          show-overflow-tooltip></el-table-column>
        <el-table-column prop="control" align="center" label="操作" fixed="right" width='110px'>
          <template slot-scope="scope">
            <el-button class="td-btn-icon" type="text" title="编辑" @click='handleTaskEdit(scope.$index, scope.row)' icon="el-icon-edit"></el-button>
            <el-button class="td-btn-icon" type="text" title="删除" @click.native.prevent="deleteRow(scope.$index, scope.row)"
              icon="el-icon-delete"></el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- 分页 -->
    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" background :current-page="currentPage"
      :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination>
    <!-- 新增/编辑-->
    <el-dialog :title="dialogTitle" :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisible">
      <el-form label-width="150px" ref="formData" :model="formData">
        <el-form-item label="姓名：" prop="humanArchName" :rules="[{ required: true, message: '请选择姓名', trigger: 'change'}]">
          <el-col :span="12">
            <el-input v-model="formData.humanArchId" style='display: none;'></el-input>
            <el-input placeholder="请选择人员" v-model="formData.humanArchName" readonly>
              <el-button slot="append" icon="el-icon-search" @click="selectHumanArchNameName"></el-button>
            </el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="证书名称" prop="certificateName" :rules="{required: true, message: '请填写证书名称'}">
          <el-col :span="12">
            <el-input v-model="formData.certificateName" auto-complete="off" placeholder="请填写证书名称"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="证书编码">
          <el-col :span="12">
            <el-input v-model="formData.certificateCode" auto-complete="off" placeholder="请填写证书编码"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="证书类别">
          <el-col :span="12">
            <el-input v-model="formData.certificateType" auto-complete="off" placeholder="请填写证书类别"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="级别">
          <el-col :span="12">
            <el-input v-model="formData.certificateLevel" auto-complete="off" placeholder="请填写级别"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="专业">
          <el-col :span="12">
            <el-input v-model="formData.speciality" auto-complete="off" placeholder="请填写专业"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="发证机构">
          <el-col :span="12">
            <el-input v-model="formData.certifyOrg" auto-complete="off" placeholder="请填写发证机构"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="发证日期">
          <el-col :span="12">
            <el-date-picker v-model="formData.certifyDate" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
              value-format="yyyy-MM-dd">
            </el-date-picker>
          </el-col>
        </el-form-item>
        <el-form-item label="有效起始日期">
          <el-col :span="12">
            <el-date-picker v-model="formData.validStartDate" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
              value-format="yyyy-MM-dd">
            </el-date-picker>
          </el-col>
        </el-form-item>
        <el-form-item label="有效到期日期">
          <el-col :span="12">
            <el-date-picker v-model="formData.validEndDate" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
              value-format="yyyy-MM-dd">
            </el-date-picker>
          </el-col>
        </el-form-item>
        <el-form-item label="复审日期">
          <el-col :span="12">
            <el-date-picker v-model="formData.verifyExpireDate" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
              value-format="yyyy-MM-dd">
            </el-date-picker>
          </el-col>
        </el-form-item>
        <el-form-item label="备注">
          <el-col :span="12">
            <el-input v-model="formData.certificateDesc" type="textarea" :autosize="{ minRows: 3, maxRows: 4}"
              auto-complete="off" placeholder="请填写备注"></el-input>
          </el-col>
        </el-form-item>
        <!-- <el-form-item>
          <el-col :span="12">
            <el-upload class="upload-demo" action="/api/ccms/org/employee/photo" :on-change="handleChange"
            :auto-upload="false"  :file-list="fileLists" :headers="{Authorization: this.Authorization}">
              <el-button size="small" type="primary">证书上传</el-button>
            </el-upload>
          </el-col>
        </el-form-item> -->
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" v-if='dialogTitle=="新增"' @click="handleAddSave('formData')">保存并继续 <i class="el-icon-document-checked"></i></el-button>
        <el-button type="primary" @click="addOrEdit('formData')">保存 <i class="el-icon-document-checked"></i></el-button>
        <el-button type="danger" @click="handleAddSaveClose">关闭 <i class="el-icon-close"></i></el-button>
      </span>
    </el-dialog>
    <!-- 高级查询 -->
    <el-drawer title="高级查询" :before-close="handleAgentSearchClose" :visible.sync="dialogAgentSearchVisible" direction="rtl"
      custom-class="demo-drawer" ref="drawer" :close-on-press-escape="false">
      <div class="demo-drawer__content el-box-column" style="height: 100%; margin-left: 18px;">
        <el-form label-width="100px" :model="seniorFormData" ref="seniorFormData" class="el-flex">
          <el-form-item label="档案编码:">
            <el-col :span="18">
              <el-input placeholder="请输入档案编码" v-model="seniorFormData.humanArchCode"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="姓名:">
            <el-col :span="18">
              <el-input placeholder="请输入姓名" v-model="seniorFormData.humanArchName"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="证件类型:">
            <el-col :span="16">
              <el-select placeholder="请选择证件类型" v-model="seniorFormData.cardType">
                <el-option v-for="item in cardTypeDatas" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-col>
          </el-form-item>
          <el-form-item label="证件号:">
            <el-col :span="12">
              <el-input placeholder="请输入证件号" v-model="seniorFormData.cardNo"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="证书类型:">
            <el-col :span="18">
              <el-input placeholder="请输入证书类型" v-model="seniorFormData.certificateType"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="发证日期:">
            <el-col :span="18">
              <el-date-picker v-model="seniorFormData.certifyDate" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
                value-format="yyyy-MM-dd">
              </el-date-picker>
            </el-col>
          </el-form-item>
          <el-form-item label="复审日期:">
            <el-col :span="18">
              <el-date-picker v-model="seniorFormData.verifyExpireDate" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
                value-format="yyyy-MM-dd">
              </el-date-picker>
            </el-col>
          </el-form-item>
          <el-form-item label="有效起始日期:">
            <el-col :span="18">
              <el-date-picker v-model="seniorFormData.validStartDate" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
                value-format="yyyy-MM-dd">
              </el-date-picker>
            </el-col>
          </el-form-item>
          <el-form-item label="有效到期日期:">
            <el-col :span="18">
              <el-date-picker v-model="seniorFormData.validEndDate" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
                value-format="yyyy-MM-dd">
              </el-date-picker>
            </el-col>
          </el-form-item>
        </el-form>
        <div class="demo-drawer__footer" style="text-align: right; margin-bottom: 10px; padding-right:10px;">
          <el-button type="primary" @click="handleSearchSure">
            确定
            <i class="el-icon-document-checked el-icon"></i>
          </el-button>
          <el-button @click="handleSearchClose">
            重置
            <i class="el-icon-refresh-left"></i>
          </el-button>
        </div>
      </div>
    </el-drawer>
    <!-- 批量导入新增弹框 -->
    <el-dialog class='dialog-body-style' title="批量导入新增" :visible.sync="allAdddialogVisible" width="20%"
      :close-on-click-modal="false" :close-on-press-escape="false">
      <el-form>
        <el-form-item>第一步：导出模板</el-form-item>
        <el-form-item>导出标准模板</el-form-item>
        <el-form-item>
          <el-button type="primary" @click="excelDownload">导出模板</el-button>
        </el-form-item>
        <el-form-item>第二步：导入文件</el-form-item>
        <el-form-item>导入</el-form-item>
        <el-form-item>
          <el-upload class="upload-demo" ref="upload" action="/api/ccms/org/human/certificate/import" :headers="{Authorization: this.Authorization}"
            :show-file-list='false' :on-success="handleSuccess" :before-upload='handleBefore' :file-list="fileList">
            <el-button slot="trigger" size="small" type="primary">导入文件</el-button>
          </el-upload>
        </el-form-item>
      </el-form>
    </el-dialog>
    <!-- 批量导入编辑弹框 -->
    <el-dialog class='dialog-body-style' title="批量导入更新" :visible.sync="allEditdialogVisible" width="20%"
      :close-on-click-modal="false" :close-on-press-escape="false">
      <el-form>
        <el-form-item>第一步：导出模板</el-form-item>
        <el-form-item>导出已有信息进行编辑</el-form-item>
        <el-form-item>
          <el-button type="primary" @click="excelDownload">导出记录</el-button>
        </el-form-item>
        <el-form-item>第二步：导入文件</el-form-item>
        <el-form-item>导入编辑更新后的信息</el-form-item>
        <el-form-item>
          <el-upload class="upload-demo" ref="upload" action="/api/ccms/org/human/certificate/import" :headers="{Authorization: this.Authorization}"
            :show-file-list='false' :on-success="handleSuccess" :before-upload='handleBefore' :file-list="fileList">
            <el-button slot="trigger" size="small" type="primary">导入文件</el-button>
          </el-upload>
        </el-form-item>
      </el-form>
    </el-dialog>
    <!-- 批量上传 结果报错-->
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" title="批量上传结果" :visible.sync="errorTableDdialog">
      <el-table border width="100%" stripe ref="errorTable" :data="errorTable">
        <el-table-column type="index" min-width="50px" label="序号" align="center" sortable show-overflow-tooltip></el-table-column>
        <el-table-column label="失败原因" min-width="100px">
          <template slot-scope="scope">
            {{scope.row}}
          </template>
        </el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button type="danger" @click="errorTableDdialog = false">关闭 <i class="el-icon-close"></i></el-button>
      </span>
    </el-dialog>
    <selectPersonDalog :dialogPersonnelVisible="dialogPerson" @dialogEmployeesData="dialogissuerCheckSure" />
  </div>

</template>
<script>
  import {
    Tree,
    Dialog,
    Table,
    TableColumn,
    Pagination,
    MessageBox,
    Message,
    Tag,
    Upload,
    Drawer,
    Radio,
    datePicker,
    Popover,
    Link
  } from 'element-ui'
  import {
    archiveList, //人员档案证书/证件列表查询
    addOrEditArchive, //新增和编辑人员档案证书/证件
    archiveSearch, //按人员名字模糊搜索
    seniorSearch, //人员档案证书/证件高级查询
    deleteArchive, //删除人员档案证书/证件
  } from '@/api/org/peopleArchives/certificateArchives.js'
  import {
    comboBoxDataSelect, //下拉通用接口
  } from '@/api/org/peopleArchives/informationArchives.js'
  import selectPersonDalog from "./selectPerson"
  export default {
    name: 'certificateArchives.vue',
    components: {
      'el-tree': Tree, //树形菜单
      'el-dialog': Dialog, //对话框
      'el-table': Table, //表格
      'el-table-column': TableColumn, //表格列
      'el-pagination': Pagination, //分页
      'el-tag': Tag, //标签
      'el-upload': Upload,
      'el-drawer': Drawer,
      'el-radio': Radio,
      'el-date-picker': datePicker,
      'el-popover': Popover,
      'el-link': Link,
      selectPersonDalog
    },
    data() {
      return {
        seniorFormData: { //高级查询条件
          humanArchCode: '',
          humanArchName: '',
          cardType: '',
          cardNo: '',
          certificateType: '',
          certifyDate: '',
          validEndDate: '',
          validStartDate: '',
          verifyExpireDate: '',
        },
        dialogAgentSearchVisible: false, //高级查询弹框
        dialogVisible: false, //新增弹框
        formData: { //新增/编辑表单
          humanArchId: '',
          humanArchName: '',
          certificateName: '',
          certificateCode: '',
          certificateType: '',
          certificateLevel: '',
          speciality: '',
          certifyOrg: '',
          certifyDate: '',
          validEndDate: '',
          validStartDate: '',
          verifyExpireDate: '',
          certificateDesc: '',
        },
        genderDatas: [], //性别
        cardTypeDatas: [], //证件类型
        politicalPlaceDatas: [], //政治面貌
        nationDatas: [], //民族
        dialogTitle: '', //新增/编辑弹框标题
        textSearch: '', //普通查询搜索
        pageSize: 0, //当前条数
        total: 0, //总条数
        currentPage: 0, //当前页数
        tableData: [], //表格数据源
        searchType: 1, //查询类型
        dialogPerson: false, //选人
        allAdddialogVisible: false, //批量导入新增弹框
        allEditdialogVisible: false, //批量导入新增弹框
        fileList: [], //上传列表
        Authorization: '',
        errorTableDdialog: false, //上传错误弹框
        errorTable: [], //错误表格数据
        fileLists: [] //证书
      }
    },
    created() {
      this.Authorization = this.getCookie('Authorization')
      this.initializationTable()
      this.getCardType()
      window.onresize = () => {
        this.$refs.tableData.doLayout()
      }
    },
    methods: {
      getCookie(cname) { // 获取cookie
        var name = cname + "="
        var ca = document.cookie.split(';')
        for (var i = 0; i < ca.length; i++) {
          var c = ca[i].trim()
          if (c.indexOf(name) == 0) return c.substring(name.length, c.length)
        }
        return ""
      },
      getLists(data) { //获取列表信息
        archiveList(data).then(res => {
          if (res.data.code == 10000) {
            this.tableData = res.data.data.records
            this.total = res.data.data.total
          }
        })
      },
      initializationTable() { //初始化表格
        this.searchType = 1
        this.currentPage = 1
        this.pageSize = 20
        let data = {
          page: this.currentPage,
          size: this.pageSize
        }
        this.getLists(data)
      },
      getCardType() { //获取证件类型
        comboBoxDataSelect('e0f6e9c1721f4a939b5524fb44ea9fea').then(res => {
          if (res.data.code == 10000) {
            this.cardTypeDatas = res.data.data
          }
        })
      },
      selectHumanArchNameName() { //选人
        this.dialogPerson = true
      },
      dialogissuerCheckSure(data) { //子传父
        this.dialogPerson = false
        if (!data) {
          return
        }
        this.formData.humanArchName = data[0].humanArchName
        this.formData.humanArchId = data[0].humanArchId
      },
      addOrEdit(formName) { //新增/编辑
        this.$refs[formName].validate((valid) => {
          if (valid) {
            let data = this.formData
            delete data.humanArchName
            addOrEditArchive(data).then(res => {
              if (res.data.code == 10000) {
                this.dialogVisible = false
                Message({
                  type: 'success',
                  message: '保存成功！'
                })
                this.initializationTable()
              }
            })
          }
        })
      },
      handleAddSave(formName) { //保存并继续
        this.$refs[formName].validate((valid) => {
          if (valid) {
            let data = this.formData
            delete data.humanArchName
            addOrEditArchive(data).then(res => {
              if (res.data.code == 10000) {
                this.clearFormData()
                setTimeout(() => {
                  this.$refs[formName].resetFields()
                }, 10)
                Message({
                  type: 'success',
                  message: '保存成功！'
                })
                this.initializationTable()
              }
            })
          }
        })
      },
      handleAddSaveClose() { //新增/编辑取消
        this.dialogVisible = false
      },
      deleteRow(index, row) {
        MessageBox.confirm('您是否确定删除选中内容', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          deleteArchive(row.archCertificateId).then(res => {
            if (res.data.code == 10000) {
              Message({
                type: 'success',
                message: '删除成功！'
              })
              this.initializationTable()
            }
          })
        })
      },
      handleTaskEdit(index, row) { //编辑
        this.dialogTitle = '编辑'
        if (this.$refs.formData != undefined) {
          setTimeout(() => {
            this.$refs.formData.clearValidate()
          }, 10)
        }
        this.dialogVisible = true
        this.$nextTick(() => {
          this.formData = JSON.parse(JSON.stringify(row))
        })
      },
      clearFormData() { //清空表单
        this.formData = {
          humanArchId: '',
          humanArchName: '',
          certificateName: '',
          certificateCode: '',
          certificateType: '',
          certificateLevel: '',
          speciality: '',
          certifyOrg: '',
          certifyDate: '',
          validEndDate: '',
          validStartDate: '',
          verifyExpireDate: '',
          certificateDesc: '',
        }
        this.fileLists = []
      },
      handleTaskAdd() { //新增
        this.dialogTitle = '新增'
        this.clearFormData()
        if (this.$refs.formData != undefined) {
          setTimeout(() => {
            this.$refs.formData.resetFields()
          }, 10)
        }
        this.dialogVisible = true
      },
      searchClear() { //普通搜索清空
        this.initializationTable()
      },
      searchTabel() { //普通搜索
        this.searchType = 2
        this.currentPage = 1
        this.pageSize = 20
        let data = {
          name: this.textSearch,
          page: this.currentPage,
          size: this.pageSize
        }
        if (data.name && data.name != '/' && data.name != '\\' && data.name != '|') {
          archiveSearch(data).then(res => {
            if (res.data.code == 10000) {
              this.tableData = res.data.data.records
              this.total = res.data.data.total
            }
          })
        }
      },
      seniorSearchDialog() { //高级查询弹框显示
        this.textSearch = ''
        this.dialogAgentSearchVisible = true
      },
      handleAgentSearchClose() { //高级查询弹框关闭事件
        this.dialogAgentSearchVisible = false;
      },
      handleSearchSure() { //高级查询确认
        this.searchType = 3
        this.currentPage = 1
        this.pageSize = 20
        let data = this.seniorFormData
        data.page = this.currentPage
        data.size = this.pageSize
        seniorSearch(data).then(res => {
          if (res.data.code == 10000) {
            this.tableData = res.data.data.records
            this.total = res.data.data.total
          }
        })
        this.dialogAgentSearchVisible = false;
      },
      handleSearchClose() { //高级查询点击弹框取消事件
        this.dialogAgentSearchVisible = false;
        this.seniorFormData = {
          humanArchCode: '',
          humanArchName: '',
          cardType: '',
          cardNo: '',
          certificateType: '',
          certifyDate: '',
          validEndDate: '',
          validStartDate: '',
          verifyExpireDate: '',
        }
        this.initializationTable()
      },
      pageSame() { //分页相同方法
        if (this.searchType == 1) {
          let data = {
            page: this.currentPage,
            size: this.pageSize
          }
          this.getLists(data)
        }
        if (this.searchType == 2) {
          let data = {
            name: this.textSearch,
            page: this.currentPage,
            size: this.pageSize
          }
          archiveSearch(data).then(res => {
            if (res.data.code == 10000) {
              this.tableData = res.data.data.records
              this.total = res.data.data.total
            }
          })
        }
        if (this.searchType == 3) {
          let data = this.seniorFormData
          data.page = this.currentPage
          data.size = this.pageSize
          seniorSearch(data).then(res => {
            if (res.data.code == 10000) {
              this.tableData = res.data.data.records
              this.total = res.data.data.total
            }
          })
        }
      },
      handleSizeChange(val) { //每页条数
        setTimeout(() => {
          this.pageSize = val
          this.pageSame()
        }, 10)
      },
      handleCurrentChange(val) { //当前页
        this.currentPage = val
        this.pageSame()
      },
      allAdd() { //批量导入新增
        this.allAdddialogVisible = true
      },
      allEdit() { //批量导入编辑
        this.allEditdialogVisible = true
      },
      handleSuccess(response, file, fileList) { //上传成功
        if (response.code == 10000 && response.data == true) {
          Message({
            message: '上传成功',
            type: 'success'
          });
        } else {
          if (response.data == null) {
            Message({
              message: response.msg,
              type: 'error'
            });
          } else {
            this.errorTableDdialog = true
            this.errorTable = response.data
          }

        }
        this.fileList = []
        this.initializationTable()
      },
      handleBefore(file) { //文件上传之前
        let fileTextClass = file.name.substring(file.name.lastIndexOf(".") + 1);
        const fileTextStyle = fileTextClass === "xlsx" || fileTextClass === "xls"
        if (!fileTextStyle) {
          Message({
            message: "上传文件只能是xlsx / xls 格式!",
            type: "error"
          })
        }
      },
      excelDownload() { //模板下载
        this.axios({
          url: 'org/template/certificate',
          method: 'GET',
          responseType: 'blob',
        }).then((response) => {
          let fileName = response.headers['content-disposition']
          let realFileName = ""
          realFileName = fileName.substring(21, fileName.length - 1);
          const url = window.URL.createObjectURL(new Blob([response.data]));
          const link = document.createElement('a');
          link.href = url;
          link.setAttribute('download', realFileName);
          document.body.appendChild(link);
          link.click();
        })
      },
      handleChange(file, fileList) {
        this.fileList = fileList.slice(-3);
      }
    }
  };
</script>

<style lang="scss">
</style>
